package com.jumi.microservice.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jumi.microservice.entity.CommonGroup;
import com.jumi.microservice.enums.CommonEnum;
import com.jumi.microservice.service.IJmUserTeamService;
import com.jumi.microservice.entity.JmUserTeam;
import com.jumi.microservice.mapper.JmUserTeamMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 要挑客户管理团队
 * @since 2020-07-14
 */
@Service
public class JmUserTeamServiceImpl extends ServiceImpl<JmUserTeamMapper, JmUserTeam> implements IJmUserTeamService {

    @Resource
    JmUserTeamMapper teamMapper;

    @Override
    public Integer getSumChiNum(QueryWrapper wrapper) {
        return teamMapper.getSumChiNum(wrapper);
    }

    @Override
    public Page getMyTeam(Page page, QueryWrapper wrapper, Integer teamUid,boolean onlyDirect) {
        if(onlyDirect){
         return teamMapper.getMyDirectTeam(page,wrapper, teamUid);
        }
        return teamMapper.getMyTeam(page,wrapper, teamUid);
    }

    @Override
    public List<JmUserTeam> getMySupers(Integer uid) {
        QueryWrapper wrapper=new QueryWrapper();
        wrapper.eq("uid",uid);wrapper.eq("is_del", CommonEnum.否);
        return list(wrapper);
    }

    @Override
    public List<CommonGroup> getTeamNumsByInviterType(QueryWrapper wrapper) {
        return teamMapper.getTeamNumsByInviterType(wrapper);
    }
}
